#!/usr/bin/env python

import sys
import urllib2
import xml.dom.minidom

def getText(nodelist):
    rc = ""
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc = rc + node.data
    return rc

def main(args=None):
    if args == None:
        args = sys.argv[1:]


    baseUrl = 'http://labs.oclc.org/xisbn/'
    data = urllib2.urlopen(baseUrl + args[0]).read()
    #print data


    dom = xml.dom.minidom.parseString(data)
    isbnNodes = dom.getElementsByTagName('isbn')
    isbns = [getText(x.childNodes) for x in isbnNodes]

    print '\n'.join(isbns)

    return 0


if __name__ == '__main__':
    sys.exit(main())

